/// @tags:
#include <algorithm>
#include <cctype>
#include <cstdio>
using std::max;
using std::min;

namespace BlueQuantum {

typedef long long ll;

int const N = 2e5 + 5, M = 3e3 + 5, mod = 998244353;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

inline int qpow(ll base, int exp) {
  ll res = 1;
  while (exp) {
    if (exp & 1) res = res * base % mod;
    exp >>= 1;
    base = base * base % mod;
  }
  return res;
}

int n, m;
int a[N], w[N], inv[M << 1], sum[3], f[M][M], g[M][M];

inline int main() {
  read(n), read(m);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= n; ++i) {
    read(w[i]);
    sum[a[i]] += w[i];
    sum[2] += w[i];
  }
  for (int i = max(0, m - sum[0]); i <= 2 * m; ++i)
    inv[i] = qpow(sum[2] + i - m, mod - 2);
  for (int i = m; ~i; --i) {
    f[i][m - i] = g[i][m - i] = 1;
    for (int j = min(m - i - 1, sum[0]); ~j; --j) {
      f[i][j] =
          (1ll * (sum[1] + i + 1) * f[i + 1][j] + 1ll * (sum[0] - j) * f[i][j + 1]) %
          mod * inv[i - j + m] % mod;
      g[i][j] =
          (1ll * (sum[1] + i) * g[i + 1][j] + 1ll * (sum[0] - j - 1) * g[i][j + 1]) %
          mod * inv[i - j + m] % mod;
    }
  }
  for (int i = 1; i <= n; ++i)
    printf("%lld\n", 1ll * w[i] * (a[i] ? f[0][0] : g[0][0]) % mod);
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("video.in", "r", stdin);
  freopen("video.out", "w", stdout);
#endif
#endif

  return BlueQuantum::main();
}